package com.bigknow.appstore.proxy.entity;

import com.bigknow.appstore.proxy.enumerate.SecurityType;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Index;
import org.mongodb.morphia.annotations.Indexed;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.concurrent.atomic.AtomicLong;

/**
 * 流量控制的统计记录对象,每个proxy资源只有一条记录
 * Created by chaos on 2016/9/28.
 */
@Entity("web.appstore.proxy.tclog")
public class TCLog implements Serializable {

    @Id
    private String id;

    @Indexed
    private String resId;

    private SecurityType securityType;

    private long currentDate;

    /**
     * 当天的统计数据，过了当天就自动清0再重新累加
     */
    private AtomicLong currentValueOfDay = new AtomicLong(0);

    /**
     * 当月的统计数据，过了这个月就自动清0再重新累加
     */
    private AtomicLong currentValueOfMonth = new AtomicLong(0);

    /**
     * 当年的统计数据，过了当年就自动清0再重新累加
     */
    private AtomicLong currentValueOfYear = new AtomicLong(0);

    private AtomicLong total = new AtomicLong(0);

    public long getCurrentDate() {
        return currentDate;
    }

    public void setCurrentDate(long currentDate) {
        this.currentDate = currentDate;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getResId() {
        return resId;
    }

    public void setResId(String resId) {
        this.resId = resId;
    }

    public SecurityType getSecurityType() {
        return securityType;
    }

    public void setSecurityType(SecurityType securityType) {
        this.securityType = securityType;
    }

    public AtomicLong getCurrentValueOfDay() {
        return currentValueOfDay;
    }

    public void setCurrentValueOfDay(AtomicLong currentValueOfDay) {
        this.currentValueOfDay = currentValueOfDay;
    }

    public AtomicLong getCurrentValueOfMonth() {
        return currentValueOfMonth;
    }

    public void setCurrentValueOfMonth(AtomicLong currentValueOfMonth) {
        this.currentValueOfMonth = currentValueOfMonth;
    }

    public AtomicLong getCurrentValueOfYear() {
        return currentValueOfYear;
    }

    public void setCurrentValueOfYear(AtomicLong currentValueOfYear) {
        this.currentValueOfYear = currentValueOfYear;
    }

    public AtomicLong getTotal() {
        return total;
    }

    public void setTotal(AtomicLong total) {
        this.total = total;
    }
}
